package com.robot.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created with IntelliJ IDEA.
 * User: li
 * Date: 2019/6/23
 * Time: 14:46
 * PROJECT：robot
 * PACKAGE: com.robot
 *
 * @author:55324936@qq.com To change this template use File | Settings | File Templates.
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor=new LoginInterceptor();
//        代表拦截所有的请求，而且拦截住之后会进入到loginInterceptor拦截器里面
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
        .excludePathPatterns("/login/loginPage").excludePathPatterns("/login/login")
        .excludePathPatterns("/login/registerPage").excludePathPatterns("/login/register");
        //把注册页面、注册请求、登录页面、登录请求排除掉
        super.addInterceptors(registry);
    }
}
